package cn.kent.fixsidetouch;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;

@SuppressLint("ApplySharedPref")
public class PrefUtils {
    private final String sideBarEnabled = "sideBarEnabled";
    private final String sideBarPercent = "sideBarPercent";

    public static final class HOLDER {
        private static final PrefUtils INSTANCE = new PrefUtils(Utils.getContext());
    }

    public static PrefUtils getInstance() {
        return HOLDER.INSTANCE;
    }

    private final SharedPreferences mPref;

    public PrefUtils(Context context) {
        mPref = context.getSharedPreferences("sideBar", Context.MODE_PRIVATE);
    }

    public boolean getSideBarEnabled() {
        return mPref.getBoolean(sideBarEnabled, false);
    }

    public void setSideBarEnabled(boolean enabled) {
        mPref.edit().putBoolean(sideBarEnabled, enabled).commit();
    }

    public int getSideBarPercent() {
        return mPref.getInt(sideBarPercent, 5);
    }

    public void setSideBarPercent(int percent) {
        mPref.edit().putInt(sideBarPercent, percent).commit();
    }


}
